home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / execbep.com / EXECBEEP.ORG < prev    next >
Encoding:
Text File  |  1987-10-28  |  1.7 KB  |  91 lines

  1. name execbeep
  2.  
  3. dp        equ    dword ptr
  4. of        equ    offset
  5.  
  6. code        segment
  7.         assume    cs:code, ds:code
  8.         org    100h
  9.  
  10. begin:        jmp    start
  11.  
  12. beep        proc            ; beep the speaker
  13.         push    ax        ; save
  14.         push    cx
  15.         in    al,97        ; get port values
  16.         and    al,0feh        ; turn speaker on
  17.         out    97,al
  18.         mov    cx,bx        ; cycles to cx
  19. more_sound:    push    cx        ; save cycles
  20.         xor    al,2        ; flip push/pull
  21.         out    97,al
  22.         mov    cx,dx        ; wait
  23. part1:        loop    part1
  24.         xor    al,2        ; flip push/pull
  25.         out    97,al
  26.         mov    cx,dx        ; wait
  27. part2:        loop    part2
  28.         pop    cx
  29.         loop    more_sound
  30.         pop    cx        ; restore
  31.         pop    ax
  32.         ret
  33. beep        endp
  34.  
  35. beep_low    proc
  36.         push    bx
  37.         push    dx
  38.         mov    bx,50        ; number of cycles
  39.         mov    dx,100        ; half cycle time
  40.         call    beep
  41.         pop    dx
  42.         pop    bx
  43.         ret
  44. beep_low    endp
  45.  
  46. beep_high    proc
  47.         push    bx
  48.         push    dx
  49.         mov    bx,100        ; number of cycles
  50.         mov    dx,50        ; half cycle time
  51.         call    beep
  52.         pop    dx
  53.         pop    bx
  54.         ret
  55. beep_high    endp
  56.  
  57. old_int21    dw    2 dup(?); former int 21h address
  58.  
  59. new_int21    proc    far
  60.         cmp    ah,4bh        ; EXEC function?
  61.         je    exec_beep    ; yes, beep, then call EXEC
  62.         cmp    ah,4dh        ; request to get return code?
  63.         je    retc_beep    ; yes, beep then get return code
  64.         jmp    dp cs:old_int21    ; no, pass it on
  65.  
  66. exec_beep:    call    beep_low    ; beep before EXEC
  67.         jmp    dp cs:old_int21    ; go do EXEC
  68.  
  69. retc_beep:    call    beep_high    ; beep after EXEC
  70.         jmp    dp cs:old_int21    ; go get return code
  71. new_int21    endp
  72.  
  73. start:        mov    ax,3521h    ; get int 21h
  74.         int    21h
  75.         mov    old_int21,bx    ; store offset
  76.         mov    old_int21+2,es    ; store segment
  77.         mov    dx,of new_int21    ; ds:dx -> new int 21h
  78.         mov    ax,2521h
  79.         int    21h
  80.         mov    dx,of start    ; discard excess
  81.         add    dx,0fh
  82.         shr    dx,1
  83.         shr    dx,1
  84.         shr    dx,1
  85.         shr    dx,1
  86.         mov    ax,3100h    ; keep process
  87.         int    21h
  88.  
  89. code        ends
  90.         end    begin
  91.